package comday08.itheima01;

public class Demo03 {
    public static void main(String[] args) {
        //每次new都会开启新空间,堆内存
        String s1 = new String("abc");
        String s2 = new String("abc");

        //""字符串只要内容一样,就只会创建一次,在常量池
        String s3 = "abc";
        String s4 = "abc";

        //==判断地址值是否相同
        System.out.println(s1 == s2);  //flase
        System.out.println(s2 == s3);  //false
        System.out.println(s3 == s4);  //true


        //equals()		:判断两个字符串的内容是否相同
        System.out.println(s1.equals(s2));  //true
        System.out.println(s2.equals(s3));  //true
        System.out.println(s3.equals(s4));  //true


    }
}
